<?
//рус
include_once (_CORE_PATH . "decorator_prototype.php");
class decorator_media extends decorator_prototype_class
{
    protected function DefaultTmp ()
    {
       
    }

    protected function JSTmp ()
    {
        $this->SetPublicStaticHeaders();             
        $this->Response()->SetHeader('Content-Type', 'application/x-javascript; charset=UTF-8');       
    }    

    protected function CSSTmp ()
    {
        $this->SetPublicStaticHeaders();              
        $this->Response()->SetHeader('Content-Type', 'text/css; charset=UTF-8');       
    }     

    protected function HTMLTmp ()
    {
        $this->SetPublicStaticHeaders();              
        $this->Response()->SetHeader('Content-Type', 'text/html; charset=UTF-8');       
    }     
    
    protected function EmptyTmp ()
    {
        $this->Response()->SetHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0', true);
        $this->Response()->SetHeader('Pragma', 'no-cache', true);
        $this->Response()->SetHeader('Expires', gmdate('D, d M Y H:i:s', time() - 1) . 'GMT', true); 
            	
        $this->Response()->SetHeader('Content-Type', 'text/html; charset=UTF-8');
        $t = $this->GetTemplator();
        $t->metaTitle = $this->GetSecondAction('Meta Title');
        $t->content = $this->Response()->GetBody();
        $this->Response()->SetBody($t->render('_empty_template.phtml'));
    }
    
    protected function ImageTmp ()
    {
        $imageInfo = $this->GetSecondAction('imageInfo');
        
        $this->SetPublicStaticHeaders();
        $this->Response()->SetHeader('Content-Length', $imageInfo['filesize']);
        $this->Response()->SetHeader('Content-Type', $imageInfo['mime']);       
    }

    protected function SetPublicStaticHeaders()
    {
        $maxAgeSec = 2593000;
        $this->Response()->SetHeader('Cache-Control', 'max-age=' .$maxAgeSec. ', public', true);
        $this->Response()->SetHeader('Pragma', '', true);
        $this->Response()->SetHeader('Set-Cookie', '', true);
        $this->Response()->SetHeader('Accept-Ranges', 'bytes', true);
        $this->Response()->SetHeader('Expires', gmdate('D, d M Y H:i:s', time() + $maxAgeSec) . ' GMT', true);
        $this->Response()->SetHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT', true);        
    }
}